<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>社区民警查询</title>
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/wechat/css/global.css'/>">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/wechat/css/base.css'/>">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/wechat/css/style.css'/>">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/wechat/css/frozen1.css'/>" />
    <link href="<c:url value='/resource/wx/newcss/main.css'/>" rel="stylesheet"/>
    <style>
        .weui_cells {
            margin-top: 1.17647059em;
            background-color: #FFFFFF;
            line-height: 1.41176471;
            font-size: 17px;
            overflow: hidden;
            position: relative;
        }
        .weui_cells:before {
            content: " ";
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 1px;
            border-top: 1px solid #D9D9D9;
            color: #D9D9D9;
            -webkit-transform-origin: 0 0;
            transform-origin: 0 0;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
        }
        .weui_cells:after {
            content: " ";
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 1px;
            border-bottom: 1px solid #D9D9D9;
            color: #D9D9D9;
            -webkit-transform-origin: 0 100%;
            transform-origin: 0 100%;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
        }
        .weui_cells_access .weui_cell:not(.no_access) {
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        }
        .weui_cells_access .weui_cell:not(.no_access):active {
            background-color: #ECECEC;
        }
        .weui_cells_access a.weui_cell {
            color: inherit;
        }
        .weui_cells_access .weui_cell_ft:after {
            content: " ";
            display: inline-block;
            -webkit-transform: rotate(45deg);
            transform: rotate(45deg);
            height: 6px;
            width: 6px;
            border-width: 2px 2px 0 0;
            border-color: #C8C8CD;
            border-style: solid;
            position: relative;
            top: -2px;
            top: -1px;
            margin-left: .3em;
        }
        .ui-container > a { margin-bottom: 15px; overflow:hidden; display:block; }
        .ui-arrowlink { line-height: 24px !important;}
        .ui-arrowlink span {min-width: 54px;}
    </style>
</head>

<div class="container-fluid">
    <form id="form">
        <div class="cells-form" style="padding: 0 10px;">
            <div class="form-box">
                <div class="form-box-hd"><label>
                    <small style="color: red">*</small>
                    查询方式：</label></div>
                <div class="form-box-bd">
                    <select name="method" id="method">
                        <c:forEach items="${methodType}" var="item">
                            <option value="${item.key}">${item.value}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>

            <div class="form-box">
                <div class="form-box-hd"><label>
                    <small style="color: red">*</small>
                    查询内容：</label></div>
                <div class="form-box-bd">
                    <input class="form-input" name="content" id="content" type="text" placeholder="请输入内容" maxlength="50" required>
                </div>
            </div>

        </div>
        <div class="btn-area">
            <a class="btn btn-orange" id="btn" type="submit" href="#">提交</a>
        </div>
    </form>
</div>
<div style="display: none" id="message">
<section class="ui-container">
    <div class="ui-newstips-wrap">
        <div class="ui-newstips">
            <div id="errormsg"></div>
        </div>
    </div>
</section>
</div>

<section id="result" class="ui-container">
</section>

<script src="<c:url value='/resource/js/jquery-2.0.min.js'/>"></script>
<script>
    $(function () {
        $("#btn").click(function () {

            var content = $("#content").val();
            if (content == "") {
                $('#message').show();
                $("#errormsg").html("请输入查询内容");
                setTimeout(function(){
                    $('#message').hide();
                },1500);
                return false;
            }

            $.ajax({
                url:"<c:url value='/api/query/search'/>",
                data:{
                    "methodType":$("#method").val(),
                    "content":$("#content").val()
                },
                type:"POST",
                success:function(res){
                    if(res.data==null){
                        $('#errormsg').empty();
                        $('#message').show();
                        $("#errormsg").html(res.msg);
                        //alert(res.data);
                        //$("#errormsg").html("没有符合项");
                        setTimeout(function(){
                            $('#message').hide();
                        },1500);
                    }

                    var htmlArr = "";
                    $('#result').empty();
                        <%--console.info(index);--%>
                        <%--console.info(police.policeName);--%>
                    $.each(res.data, function(index , police){
                        if (police.address ==null){
                            police.address ="";
                        }
                        htmlArr +=  "<a href=<c:url value='/api/query/search/"+ police.policeCode +"'/>>"+
                                "	<section class='ui-panel ui-panel-simple ui-border-tb'>"+
                                "<h2 class='ui-arrowlink'><span>"+
                                police.policeName+"</span><span class='ui-panel-subtitle' style='-webkit-box-flex: 1; padding-right: 30px;'>管辖范围："
                                +police.address+"</span></h2>"+
                                "</section>"+
                                "</a>";
                    });
                    $("#result").append(htmlArr);
                }
            })
        });
    })
</script>


</body>
</html>

